﻿@model Bricks.Site.Models.FlowRecordView
@{
    ViewBag.Title = "CirculatedFlow";
    Layout = "~/Views/Shared/_UserPage.cshtml";
}
<head>
    <title></title>
    <script type="text/javascript">
        $(function () {
            //当页面首次刷新的时候执行的事件
            var processUserDepartment = $("#hProcessUserDepartment").val();
            $('#tOrgUser').tree({
                checkbox: true,
                url: '/Flow/SetFlowCirculatedData?orgCode=' + processUserDepartment
            });
        });

        function SaveCirculatedData() {
            var nodes = $('#tOrgUser').tree('getChecked');
            var orgCodeAndUserNameStr = '';
            for (var i = 0; i < nodes.length; i++) {
                if (nodes[i].attributes.type == '1') {
                    if (orgCodeAndUserNameStr != '') {
                        orgCodeAndUserNameStr += ',';
                    }
                    var node = $('#tOrgUser').tree('getParent', nodes[i].target);
                    orgCodeAndUserNameStr += node.id + '|' + nodes[i].id;
                }
            }
            $('#frmCirculated').form('submit', {
                url: '/Flow/SaveCirculatedData?orgCodeAndUserNameStr=' + orgCodeAndUserNameStr,
                onSubmit: function () {
                    if (orgCodeAndUserNameStr == '') {
                        $.EasyuiSlide("还没有勾选用户！");
                        return false;
                    }
                },
                success: function (data) {
                    window.parent.CloseWindow(5, '传阅成功！');
                },
                fail: function (data) {
                    $.EasyuiSlide(data);
                }
            });
        }
    </script>
</head>
<body>
    <div style="padding-top:5px;padding-left: 5px;padding-right:5px;">
        <form id="frmCirculated" method="post">
            <div>
                <input type="hidden" name="RecordID" id="hid" value="@Model.RecordID" />
                <input type="hidden" name="FlowCode" id="hFlowCode" value="@Model.FlowCode" />
                <input type="hidden" name="CurrentFlowNodeCode" id="hFlowNodeCode" value="@Model.CurrentFlowNodeCode" />
                <input type="hidden" name="ProcessUserDepartment" id="hProcessUserDepartment" value="@Model.ProcessUserDepartment" />
            </div>
        </form>

        <div region="center" style="height: 300px; width: 100%; overflow: auto; ">
            <ul id="tOrgUser" fit="true"></ul>
        </div>
        <div style="margin-left: 5px; margin-top: 5px; text-align: right;">
            <input type="button" id="btnSave" value="保存" onclick="SaveCirculatedData();" />
            <input type="button" id="btnCancel" value="取消" onclick="window.parent.CloseWindow(0);" />
        </div>
    </div>
</body>
